package com.wjw.java.others.enum_;

/**
 * 自定义类实现枚举：
 * ---------------------------------------------------------------------
 * 1.构造器私有化,防止对象直接被new
 * 2.不提供setter方法,因为枚举对象值通常为只读,防止属性被修改
 * 3.对枚举对象/属性使用public static final共同修饰,实现底层优化:
 *   static final修饰的属性,不会类加载,那么静态代码块中的代码也不会被执行
 * 4.枚举对象名通常使用全部大写,常量的命令规范
 * 5.枚举对象根据需要,也可以有多个属性
 * ---------------------------------------------------------------------
 */
public class EnumClass {
    public static void main(String[] args) {
        System.out.println(SeasonClass.SPRING);
        System.out.println(SeasonClass.SUMMER);
        System.out.println(SeasonClass.AUTUMN);
        System.out.println(SeasonClass.WINTER);
    }
}
//季节类
class SeasonClass{
    private String name;//名称
    private String describe;//描述

    //1.
    private SeasonClass(String name, String describe) {
        this.name = name;
        this.describe = describe;
    }

    //2.
    public String getName() {
        return this.name;
    }
    public String getDescribe() {
        return this.describe;
    }

    //3.
    //4.
    public static final SeasonClass SPRING = new SeasonClass("春天","温暖。");
    public static final SeasonClass SUMMER = new SeasonClass("夏天","炎热。");
    public static final SeasonClass AUTUMN = new SeasonClass("秋天","凉爽。");
    public static final SeasonClass WINTER = new SeasonClass("冬天","寒冷。");

    @Override
    public String toString() {
        return "SeasonClass{" +
                "name='" + name + '\'' +
                ", describe='" + describe + '\'' +
                '}';
    }
}